package com.controller;

import com.alibaba.fastjson.JSON;
import com.entity.JsonProcess;
import com.enums.BizCodeEnum;

import java.util.Arrays;
import java.util.Iterator;
import java.util.List;



    public class JsonProcessing {
        public static void main(String[] args) {
            String message = BizCodeEnum.GROUP_ADD_FAIL.getMessage();
            System.out.println(message);
            JsonProcessing jsonProcessing = new JsonProcessing();
            List<JsonProcess> jsonProcessesList = jsonProcessing.processesList();
            Iterator<Integer> iterator = Arrays.asList(0,1).iterator();
            int i=0;
            while (iterator.hasNext()) {
                int index = iterator.next();
                if (index >= 0 && index <= jsonProcessesList.size()) {
                    String fldClass = jsonProcessesList.get(index).getFldClass();
                    System.out.println(fldClass);
                } else {
                    System.out.println("Index " + index + " is out of bounds.");
                }
            }
        }
        public  List<JsonProcess> processesList(){
            String json = "[{\"fldClass\":\"0\", \"fldNameCn\":\"Value1\"}, {\"fldClass\":\"1\", \"fldNameCn\":\"Value2\"}]";
            List<JsonProcess> jsonProcesses = JSON.parseArray(json, JsonProcess.class);
            for (JsonProcess jsonProcess : jsonProcesses) {
                String fldClass = jsonProcess.getFldClass();
                switch (Integer.parseInt(fldClass)) {
                    case 0:
                        fldClass = "非敏感字段";
                        break;
                    case 1:
                        fldClass = "对私客户中文名";
                        break;
                    case 2:
                        fldClass = "对私客户英文名";
                        break;
                    case 3:
                        fldClass = "证件号码";
                        break;
                    case 4:
                        fldClass = "性别";
                        break;
                    default:
                        fldClass = "未知类型";
                        break;
                }
                jsonProcess.setFldClass(fldClass);

            }
            System.out.println(jsonProcesses);
            return jsonProcesses;




    }



}



